<!DOCTYPE html>
<html>

<head> 
  <title>Blog Home</title>
  <link rel="stylesheet" href="stylesheets/style.css" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
</head>

<body class="bg-gray-100">
  <div class="container mx-auto px-4 py-8">
    <h1 class="text-3xl font-bold text-center mb-6">Articles</h1>
    <ul>  
      <% articles.forEach(function(article) { %>
      <li class="bg-white rounded-lg shadow overflow-hidden mb-4">
        <div class="p-5"> 
          <h2 class="text-xl font-semibold text-gray-800">
            <%= article.title %>
          </h2>
          <p class="text-gray-600 mt-2">
            <%= article.content %>
          </p>
          <div class="mt-3">
            <% if (article.articleTags && article.articleTags.length) { %>
            <small class="font-medium">Tags:</small>
            <% article.articleTags.forEach(function(tag, index) { %>
            <span class="inline-block bg-blue-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">
              <%= tag.name %><%= index < article.articleTags.length - 1 ? ', ' : '' %>
            </span>
            <% }); %>
            <% } else { %>
            <small>No tags</small>
            <% } %>
          </div>
        </div>
      </li>
      <% }); %>
    </ul>
  </div>
</body>

</html>
